<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Cadastro de Contatos</title>
    </h:head>
    <h:body>
        <h:form>
            <h:panelGrid columns="2">
                ID
                <h:inputText value="#{contatoMB.contato.id}"/>
                Nome
                <h:inputText value="#{contatoMB.contato.nome}"/>
                E-mail
                <h:inputText value="#{contatoMB.contato.email}"/>
                <h:commandButton value="Novo" 
                                 action="#{contatoMB.novo()}"/>                
                <h:commandButton value="Salvar" 
                                 action="#{contatoMB.salvar()}"/>
                <h:commandButton value="Alterar" 
                                 action="#{contatoMB.alterar()}"/>                              
                <h:commandButton value="Pesquisar"
                                 action="#{contatoMB.pesquisar()}"/>
                <h:commandButton value="Excluir"
                                 action="#{contatoMB.excluir()}"/>     
            </h:panelGrid>
        </h:form>
        <h:form>
            <h:dataTable var="contatos" value="#{contatoMB.contatos}">
                <h:column>
                    <f:facet name="header">
                        <h:commandLink value="ID" action="#{contatoMB.ordenaID()}"/>
                    </f:facet>
                    #{contatos.id}                    
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:commandLink value="Nome" action="#{contatoMB.ordenaNome()}"/>
                    </f:facet>
                    #{contatos.nome}                    
                </h:column>                
                <h:column>
                    <f:facet name="header">
                        <h:commandLink value="Email" action="#{contatoMB.ordenaEmail()}"/>
                    </f:facet>
                    #{contatos.email}                    
                </h:column>                
            </h:dataTable>
        </h:form>
    </h:body>
</html>

